package doorwifi.wd.patientsation.peripheral.mainapp.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;

import doorwifi.wd.patientsation.peripheral.mainapp.Bean.patientBedInfo;
import doorwifi.wd.patientsation.peripheral.mainapp.R;

/**
 * Created by xuhuan on 2017/7/21.
 */

public class callSickbedInfoAdapter extends RecyclerView.Adapter<callSickbedInfoAdapter.MyViewHolder> {

    private Context mcontext;
    private ArrayList<patientBedInfo> list;
    private LayoutInflater inflater;
    private sickBedInfoItemOnclickListener itemOnclickListener;

    public callSickbedInfoAdapter(Context mcontext, ArrayList<patientBedInfo> list) {
        this.mcontext = mcontext;
        this.list = list;
        inflater = LayoutInflater.from(mcontext);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.xh_call_sicked_door_adapter,parent, false);
        callSickbedInfoAdapter.MyViewHolder holder= new callSickbedInfoAdapter.MyViewHolder(view,itemOnclickListener);
//        x.view().inject(holder,view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        patientBedInfo info = list.get(position);
        holder.call_sickbed_Num.setText(info.getPatientBedNum());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    @Override
    public int getItemViewType(int position) {
        return position;
    }
    public void setillnessDoorOnItemClickListener(sickBedInfoItemOnclickListener itemOnclickListener ){
        this.itemOnclickListener = itemOnclickListener;
    }


    class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
        @ViewInject(R.id.illnessDoorNumber)
        private TextView call_sickbed_Num;
//        @ViewInject(R.id.call_illnessBedNumber)
        private ImageView illnessDoorImg;
        @ViewInject(R.id.adpater_ll)
        private LinearLayout adpater_ll;
        private sickBedInfoItemOnclickListener ItemOnclickListener;

        public MyViewHolder(View view,sickBedInfoItemOnclickListener itemOnclickListener) {
            super(view);
            call_sickbed_Num = (TextView) view.findViewById(R.id.illnessDoorNumber);
            this.ItemOnclickListener = itemOnclickListener;
            view.setOnClickListener(this);
        }
        @Override
        public void onClick(View v) {
            if(ItemOnclickListener != null){
                ItemOnclickListener.onSickBedInfoItemClick(v,getLayoutPosition());
            }
        }
    }
    public interface sickBedInfoItemOnclickListener{
        public void onSickBedInfoItemClick(View view,int position);
    }
}
